﻿using DXApplicationTangche.UC.面料审核.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.面料审核
{
    public partial class Form修改实际出库数量 : DevExpress.XtraEditors.XtraForm
    {
        private String materialRequirementId { get; set; }
        private String materialName { get; set; }
        private MaterialDetailDTO materialDetailDTO = new MaterialDetailDTO();
        private MaterialRequirementQueryDTO materialRequirementQueryDTO = new MaterialRequirementQueryDTO();

        public Form修改实际出库数量(String materialRequirementId,String materialName)
        {
            InitializeComponent();
            this.materialRequirementId = materialRequirementId;
            this.materialName = materialName;
            this.label面料号提示.Text = "面料号：" + materialName;
            this.materialDetailDTO = 面料审核Service.getMaterialDetail(materialName);
            this.materialRequirementQueryDTO = 面料审核Service.getMaterialRequirementQueryById(materialRequirementId);
        }

        private void textBox实际出库数量_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (String.IsNullOrWhiteSpace(this.textBox实际出库数量.Text.Trim()))
                {
                    MessageBox.Show("请输入实际出库数量");
                    return;
                }
                else
                {
                    //裁剪出库实际数
                    面料审核Service.modifyTailorStockOut(this.materialRequirementId, this.materialName, this.textBox实际出库数量.Text.Trim());
                    //修改出库单出库实际数
                    面料审核Service.modifyMaterialDeliveryEntry(this.materialRequirementId, this.materialDetailDTO.fmaterialid.ToString(), this.textBox实际出库数量.Text.Trim());
                    //出库单提交审核
                    面料审核Service.出库单审核提交(this.materialRequirementQueryDTO.fid, this.materialRequirementQueryDTO.fName);
                    this.Close();
                }
            }
        }
    }
}
